<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="fetchData">获取数据</button>
<script>
    //先获取按钮DOM元素
    let fetchData = document.querySelector('#fetchData');
    //给按钮绑定点击事件
    fetchData.addEventListener('click',()=>{
        //创建一个脚本
        let script = document.createElement('script');
        //指定脚本的地址
        script.src="http://localhost:3000?callback=myCallback";
        //把脚本添加到body上
        document.body.appendChild(script);
    });
    //myCallback({id:1,name:'zhufeng'});
    function myCallback(data){
        console.log(data)
    }
</script>
</body>
</html>